import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.util.Random;

/**
 * Created by ospip on 2017/11/14.
 * Copyright (c) 2017 LLAP. All rights reserved.
 */
public class Ball {
    public int time = 0;
    public int x = 0, y = 0; // y:起始高度
    public int vx = 2, vy = 0;
    public int a = 1;
    public int radius = 20;
    public static int borderx = 800, bordery = 500;

    public Ball(int x, int y) {
        this.borderx = x;
        this.bordery = y;
        this.y = (int)(Math.random() * (bordery * 2 / 3));
        this.vx = 1;
        //this.vx = (int)(Math.random() * 5) + 2;
        //this.a = (int)(Math.random() * 3) + 1;
        this.radius = (int)(Math.random() * 29) + 10;
    }

    public void update() {
        ++time;
        vy += a;
        x += vx;
        y += vy;
        if (y >= bordery) {
            y = bordery;
            //vy += a;
            vy *= -1;
        }
    }
}
